<!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="csrf-token" content="{{ csrf_token() }}">
	<link rel="stylesheet" href="/shop/style/css/ch-ui.admin.css">
    <link rel="stylesheet" href="/shop/style/font/css/font-awesome.min.css">
    <link rel="stylesheet" href="/shop/style/css/page.css">
    <script type="text/javascript" src="/shop/style/js/jquery.js"></script>
    <script type="text/javascript" src="/shop/style/js/ch-ui.admin.js"></script>
    <link rel="stylesheet" href="/houtai/layui/css/layui.css">
    <script src="/houtai/layui/layui.js"></script>
    <link rel="stylesheet" href="/shop/style/serachalbelSelect/searchableSelect.css">
    <script type="text/javascript" src="/shop/style/serachalbelSelect/jquery.searchableSelect.js"></script>

    <style>
        .tc{
            text-align:center;
        }
        a{
            color:#1963aa;
        }
    </style>
</head>
<body>
    <!--面包屑导航 开始-->
    <div class="crumb_warp">
        <!--<i class="fa fa-bell"></i> 欢迎使用登陆网站后台，建站的首选工具。-->
        <i class="fa fa-home"></i> <a href="#">首页</a> &raquo; <a href="#">商城管理</a> &raquo; 上架商品列表
    </div>
    <!--面包屑导航 结束-->

	<!--结果页快捷搜索框 开始-->
	<div class="search_wrap">
        <form action="" method="post">
            <table class="search_tab">
                <tr>

                    <th width="70">关键字:</th>
                    <td><input type="text" name="keywords" placeholder="请输入商品名" value="{{$request->keywords}}" style="width:70px"></td>
                    <th width="40">ID:</th>
                    <td><input type="text" name="gid" placeholder="请输入ID" value="{{$request->gid}}" style="width:60px"></td>
                    <th width="70">商品ID:</th>
                    <td><input type="text" name="id" placeholder="请输入商品ID" value="{{$request->id}}" style="width:75px"></td>
                    <th width="120">选择分类:</th>
                    <td style="width:160px">
                        <select name="pid" lay-verify="" lay-search id="ftype">
                            <option value="">==请选择==</option>
                            @foreach($all_list as $fvo)
                                <option value="{{$fvo->id}}" @if($request['pid'] == $fvo->id) selected @endif><?php echo str_repeat("&nbsp;",substr_count($fvo->path,',')*3);?>|--{{$fvo->name}}</option>
                            @endforeach
                        </select>
                    </td>

                    <th width="120">选择品牌:</th>
                    <td style="width:160px">
                        <select name="bid" lay-verify="" lay-search id="compayId">
                            <option value="">==请选择==</option>
                            @foreach($brand as $fvo)
                                <option value="{{$fvo->id}}" @if($request['bid'] == $fvo->id) selected @endif>{{$fvo->name_cny}}</option>
                            @endforeach
                        </select>
                    </td>

                    <th width="120">选择店铺:</th>
                    <td style="width:160px">
                        <select name="mid" lay-verify="" lay-search id="merchant">
                            <option value="">==请选择==</option>
                            @foreach($merchant as $fvo)
                                <option value="{{$fvo->id}}" @if($request['mid'] == $fvo->id) selected @endif>{{$fvo->shop}}</option>
                            @endforeach
                        </select>
                    </td>
                    <th width="120">是否同步:</th>
                    <td>
                        <select id="sub_dpi" name="is_e" lay-verify="" lay-search >
                            <option value="">==请选择==</option>
                            <option value="1" @if($request['is_e'] == 1) selected @endif>是</option>
                            <option value="2" @if($request['is_e'] == 2) selected @endif>否</option>
                        </select>
                    </td>
                    <th width="120">排序(降序):</th>
                    <td>
                        <select id="sub_sort" name="sort" lay-verify="" lay-search >
                            <option value="">==请选择==</option>
                            <option value="6" @if($request['sort'] == 6) selected @endif>ID（降）</option>
                            <option value="2" @if($request['sort'] == 2) selected @endif>店铺总数</option>
                            <option value="1" @if($request['sort'] == 1) selected @endif>价格（降）</option>
                            <option value="5" @if($request['sort'] == 5) selected @endif>价格（升）</option>
                            <option value="3" @if($request['sort'] == 3) selected @endif>利润（降）</option>
                            <option value="4" @if($request['sort'] == 4) selected @endif>利润（升）</option>
                        </select>
                    </td>
                    <td><input type="submit" name="sub" value="查询"></td>
                </tr>
            </table>
        </form>
    </div>
    <!--结果页快捷搜索框 结束-->

    <!--搜索结果页面 列表 开始-->
    <form action="#" method="post">
        <div class="result_wrap">
            <!--快捷导航 开始-->
            <div class="result_content">
                <div class="short_wrap">
                    <a href="/shop/good/add"><i class="fa fa-plus"></i>新增商品</a>
                    <a href="javascript:void(0);" onClick="tongs()"><i class="fa fa-exchange"></i>一键同步</a>
                </div>
            </div>
            <!--快捷导航 结束-->
        </div>

        <div class="result_wrap">
            <div class="result_content">
                <table class="list_tab">
                    <tr>
                        <th>ID</th>
                        <th>商品ID</th>
                        <th>商品名</th>
                        <th>成本价</th>
                        <th>销售价</th>
                        <th>专柜价</th>
                        <th>利润</th>
                        <th>店铺总数</th>
                        <th>类型</th>
                        <th>品牌</th>
                        <th>库存</th>
                        <th>是否同步</th>
                        <th>状态</th>
                        <th>创建时间</th>
                        <th>操作</th>
                    </tr>
                    @if($list->isEmpty())
                        <tr>
                            <td colspan="14" class="tc">暂无数据</td>
                        </tr>
                    @else
                        @foreach ($list as $v)
                            @if($v->status == 4)
                            <tr style="background-color:#99CCCC;">
                            @else
                            <tr >
                            @endif
                                <td>{{$v->id}}</td>
                                <td>{{$v->attr_id}}</td>
                                <td>{{$v->name}}</td>
                                <td>{{$v->price}}</td>
                                <td>
                                    @if($v->is_chage == 1)
                                        <a href="javascript:void(0);"
                                           onclick="sorts('{{$v->id}}','{{$v->new_sell_price}}')">
                                            <span style="color:red">{{$v->new_sell_price}}</span>
                                        </a>
                                    @else
                                    <a href="javascript:void(0);"
                                       onclick="sorts('{{$v->id}}','{{$v->sell_price}}')">
                                        {{$v->sell_price}}
                                    </a>
                                    @endif
                                </td>
                                <td>
                                    @if($v->is_edit_del == 1)
                                        <a href="javascript:void(0);"
                                           onclick="sorts_del('{{$v->id}}','{{$v->del_coin}}')">
                                            <span style="color:green">{{$v->del_coin}}</span>
                                        </a>
                                    @else
                                    <a href="javascript:void(0);"
                                       onclick="sorts_del('{{$v->id}}','{{$v->del_coin}}')">
                                        {{$v->del_coin}}
                                    </a>
                                    @endif
                                    </td>
                                <td>{{$v->charge}}</td>
                                
                                <td>{{$v->mer_num}}</td>
                                <td>{{$v->tname}}</td>
                                <td>{{$v->bname}}</td>
                                <td>
                                    <a href="javascript:void(0);"
                                       onclick="sorts_num('{{$v->id}}','{{$v->num}}')">
                                        {{$v->num}}
                                    </a></td>
                                <td>@if($v['state'] == 1)是 @else 否 @endif</td>
                                <td>@if($v['status'] == 1)正常 @elseif($v['status'] == 4) APP后台已删除@endif</td>
                                {{--<td><a href="/shop/good/detail?id={{$v->id}}">查看</a></td>--}}
                                <td>{{$v->created_at}}</td>
                                <td>
                                    <a href="/shop/good/edit?id={{$v->id}}">修改</a>
                                    <a href="/shop/good/shop?id={{$v->id}}">商铺价格</a>
                                    <a href="/shop/good/type?id={{$v->id}}">类型</a>
                                    <a href="javascript:void(0);" onClick="tong({{$v->id}})">同步</a>
                                    {{--<a href="javascript:void(0);" onClick="del({{$v->id}})">删除</a>--}}
                                    <a href="javascript:void(0);" onClick="config({{$v->id}})">下架</a>
                                </td>
                            </tr>
                        @endforeach
                    @endif

                </table>

                {{--<div class="page_list">--}}
                    {{--<ul>--}}
                        {{--<li class="active"><a href="#">1</a></li>--}}
                        {{--<li><a href="#">2</a></li>--}}
                        {{--<li><a href="#">3</a></li>--}}
                        {{--<li><a href="#">4</a></li>--}}
                        {{--<li><a href="#">5</a></li>--}}
                        {{--<li><a href="#">&raquo;</a></li>--}}
                    {{--</ul>--}}
                {{--</div>--}}
            </div>
            <div id="pull_right">
                <!--分页写法-->
                <div class="pull-right">
                    {{ $list->appends(['keywords'=>$request->keywords,'bid'=>$request->bid,'mid'=>$request->mid,'pid'=>$request->pid,'is_e'=>$request->is_e,'sort'=>$request->sort,'gid'=>$request->gid,'id'=>$request->id])->render() }}
                </div>
            </div>
        </div>
        <form>
            <div style="margin-top:8px;margin-left:18px">
                第&nbsp;<input type="" name="page" value="{{$pages}}" style="width:50px;border:1px solid #ddd;line-height:70px;text-align:center;height:30px;border-radius:1px">&nbsp;页
                &nbsp;&nbsp;&nbsp;&nbsp;<button class="layui-btn layui-btn-sm" lay-submit lay-filter="selectsub">跳转</button>
            </div>
            {{--<input type="hidden" name="page" value="{{$page}}">--}}
            <input type="hidden" name="keywords" value="{{$request->keywords}}">
            <input type="hidden" name="bid" value="{{$request->bid}}">
            <input type="hidden" name="mid" value="{{$request->mid}}">
            <input type="hidden" name="pid" value="{{$request->pid}}">
            <input type="hidden" name="is_e" value="{{$request->is_e}}">
            <input type="hidden" name="sort" value="{{$request->sort}}">
            <input type="hidden" name="gid" value="{{$request->gid}}">
            <input type="hidden" name="id" value="{{$request->id}}">
        </form>


    </form>
    <!--搜索结果页面 列表 结束-->

    <script>
        $(function(){
            $('#compayId').searchableSelect();
            $('#ftype').searchableSelect();
            $('#merchant').searchableSelect();
        })
        $.ajaxSetup({
            headers: {
                'X-CSRF-TOKEN': $('meta[name="csrf-token"]').attr('content')
            }
        });
        function del(id){
            layui.use('layer', function() {
                layer.confirm('确定删除?', {icon: 3, title: '提示'}, function (index) {
                    var page = $('input[name=page]').val();
                    var keywords = $('input[name=keywords]').val();
                    var bid = $('input[name=bid]').val();
                    var mid = $('input[name=mid]').val();
                    var pid = $('input[name=pid]').val();
                    var is_e = $('input[name=is_e]').val();
                    var sort = $('input[name=sort]').val();
                    var id = $("input[name=id]").val();

                    $.ajax({
                        url:'/shop/good/del',
                        type:'post',
                        async:false,
                        data:{id:id},
                        success:function(msg){
                            layer.msg(msg['msg'],{time:3000},function(){
                                location.href='/shop/good/index?page='+page+'&keywords='+keywords+'&bid='+bid+'&mid='+mid+'&pid='+pid+'&is_e='+is_e+'&sort='+sort;
                            });
                        },
                    })
                });
            });
        }

        $("#check").click(function(){
            var keywords = $("input[name=keywords]").val();
            var pid = $("select[name=pid]").val();
            location.href='/shop/good/index?keywords='+keywords+'&pid='+pid;
        })

        function tong(id){
            layui.use('layer', function() {
                var page = $('input[name=page]').val();
                var keywords = $('input[name=keywords]').val();
                var bid = $('input[name=bid]').val();
                var mid = $('input[name=mid]').val();
                var pid = $('input[name=pid]').val();
                var is_e = $('input[name=is_e]').val();
                var sort = $('input[name=sort]').val();
                layer.confirm('确定同步?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/good/synchro',
                        type:'post',
                        data:{id:id},
                        async:false,
                        success:function(msg){
                            layer.msg(msg['msg'],{time:3000},function(){
                                location.href='/shop/good/index?page='+page+'&keywords='+keywords+'&bid='+bid+'&mid='+mid+'&pid='+pid+'&is_e='+is_e+'&sort='+sort;
                            });

                        },
                    })
                });
            });
        }
        function tongs(){
            layui.use('layer', function() {
                layer.confirm('确定同步?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/good/synchro_all',
                        type:'post',
                        async:false,
                        success:function(msg){
                            layer.msg(msg['msg'],{time:3000},function(){
                                location.href='/shop/good/index';
                            });
                        },
                    })
                });
            });
        }

        function sorts(id, title) {
            layui.use('layer', function() {
            layer.prompt({
                formType: 3,
                value: title,
                title: '编辑销售价',
                offset: ['30%', '40%'],//设置位移
            }, function (value, index, elem) {
                var index = layer.load();
                $.post("/shop/good/chage_price", {
                    id: id,
                    num: value,
                    _token: "{{csrf_token()}}"
                }, function (data) {
                    layer.close(index);
                    layer.msg(data.msg);
                    if (data.code == 1) {
                        location.reload();
                    }

                })
            });
            });
        }
        //编辑专柜价
        function sorts_del(id, title) {
            layui.use('layer', function() {
            layer.prompt({
                formType: 3,
                value: title,
                title: '编辑专柜价',
                offset: ['30%', '40%'],//设置位移
            }, function (value, index, elem) {
                var index = layer.load();
                $.post("/shop/good/chage_del_price", {
                    id: id,
                    num: value,
                    _token: "{{csrf_token()}}"
                }, function (data) {
                    layer.close(index);
                    layer.msg(data.msg);
                    if (data.code == 1) {
                        location.reload();
                    }

                })
            });
            });
        }

        function sorts_num(id, title) {
            layui.use('layer', function() {
                layer.prompt({
                    formType: 3,
                    value: title,
                    title: '编辑库存',
                    offset: ['30%', '40%'],//设置位移
                }, function (value, index, elem) {
                    var index = layer.load();
                    $.post("/shop/good/chage_num", {
                        id: id,
                        num: value,
                        _token: "{{csrf_token()}}"
                    }, function (data) {
                        layer.close(index);
                        layer.msg(data.msg);
                        if (data.code == 1) {
                            location.reload();
                        }

                    })
                });
            });
        }

        function config(id){
            var page = $('input[name=page]').val();
            var keywords = $('input[name=keywords]').val();
            var bid = $('input[name=bid]').val();
            var mid = $('input[name=mid]').val();
            var pid = $('input[name=pid]').val();
            var is_e = $('input[name=is_e]').val();
            var sort = $('input[name=sort]').val();
            layui.use('layer', function() {
                layer.confirm('确定下架?', {icon: 3, title: '提示'}, function (index) {
                    $.ajax({
                        url:'/shop/good/good_down',
                        type:'post',
                        data:{id:id},
                        async:false,
                        success:function(msg){
                            layer.msg(msg['msg'],{time:3000},function(){
                                location.href='/shop/good/index?page='+page+'&keywords='+keywords+'&bid='+bid+'&mid='+mid+'&pid='+pid+'&is_e='+is_e+'&sort='+sort;
                            });
                        },
                    })
                });
            });
        }


    </script>

</body>
</html>